﻿using Daabli;

namespace ConsoleApp
{
    public abstract class Creature : IReadable<Creature>
    {
        private string _name = string.Empty;
        public string Name { get { return _name; } }

        bool IReadable<Creature>.Read(Reader r)
        {
            return r.Read("name", ref _name);
        }

        public override string ToString()
        {
            return _name;
        }
    }

    public abstract class AttackingCreature : Creature, IReadable<AttackingCreature>
    {
        private float _attackDamage = 0;
        public float AttackDamage { get { return _attackDamage; } }

        bool IReadable<AttackingCreature>.Read(Reader r)
        {
            if (!r.ReadBase(this))
                return false;

            return r.Read("attackDamage", ref _attackDamage);
        }

        public override string ToString()
        {
            return string.Format("{0}, {1}", base.ToString(), _attackDamage);
        }
    }

    public class Wolf : AttackingCreature, IReadable<Wolf>
    {
        private int _hitPoints = 0;
        public int HitPoints { get { return _hitPoints; } }

        bool IReadable<Wolf>.Read(Reader r)
        {
            if (!r.ReadBase(this))
                return false;

            return r.Read("hitPoints", ref _hitPoints);
        }

        public override string ToString()
        {
            return string.Format("{0}, {1}", base.ToString(), _hitPoints);
        }
    }
}
